// JavaScript Engine

	jQuery(document).ready(function(){
	
	Cufon.replace('#panel h1, #content h1', { color: '#91D9F5', textShadow: '1px 1px rgba(0, 0, 0, 0.3)', hover: true });
	Cufon.replace('.col2 h2, .col4 h2', { textShadow: '1px 1px rgba(255, 255, 255, 0.3)', hover: true });
	Cufon.replace('#secondary h3, #featured h3, #sidebar h2, .postcontent h2, .postcontent h3', { textShadow: '1px 1px rgba(0, 0, 0, 0.2)', hover: true });
	Cufon.replace('#secondary h1', { textShadow: '1px 1px rgba(255, 255, 255, 0.3)', hover: true });
	Cufon.replace('#flag em', { textShadow: '1px 1px rgba(0, 0, 0, 0.3)' });
	Cufon.replace('#himage h2', { textShadow: '1px 1px rgba(0, 0, 0, 0.3)' });
	
	jQuery('#slider').loopedSlider({
			container: ".slideshow",
			pagination: "pagination",
			autoStart: 2500,
			restart: 500,
			fadespeed: 200
		});
	
	// Pirobox
	jQuery('.ngg-gallery-thumbnail a, .lb a').piroBox({
			my_speed: 400, //animation speed
			bg_alpha: 0.1, //background opacity
			slideShow : false, // true == slideshow on, false == slideshow off
			slideSpeed : 4, //slideshow duration in seconds(3 to 6 Recommended)
			close_all : '.piro_close,.piro_overlay'// add class .piro_overlay(with comma)if you want overlay click close piroBox

	});
	
	// News ticker
	jQuery('#ticker').innerfade({
			speed: 2000,
			timeout: 5000,
			type: 'random',
			containerheight: '45px'
	});
	
	// Change lang
	jQuery("#flag a").hover(function() {
	jQuery(this).next("em").animate({opacity: "show", right: "40"}, "slow");
	}, function() {
	jQuery(this).next("em").animate({opacity: "hide", right: "50"}, "slow");
	});
	
		// Expand dt
	jQuery('dl#club').find('dd').hide().end().find('dt').append('<span class="open">apri</span>').toggle(function(){
				jQuery(this).find('span').attr('class','close').html('chiudi').end().next('dd').fadeIn();
			},function(){
				jQuery(this).find('span').attr('class','open').html('apri').end().next('dd').fadeOut(); 
			});
	
	// Toggle a div with extra info		
	jQuery(".extra1, .extra2").css("display","none");
		jQuery("#toggle").click(function(){
			jQuery('.extra1').toggle(400);
   			 return false;
		});	
		jQuery("#toggle2").click(function(){
			jQuery('.extra2').toggle(400);
   			 return false;
		});	
		
	// Back to top
	jQuery(window).scroll(function () {  
        if (jQuery(this).scrollTop() != 0) {  
            jQuery('#top').fadeIn();  
        } else {  
            jQuery('#top').fadeOut();  
        }  
    });  
    jQuery('#top').click(function () {  
        jQuery('body,html').animate({  
            scrollTop: 0  
        },  
        800);  
    });
    
	// Datepicker
		jQuery('#dal,#al').focus(function(){jQuery(this).val('');})
		.datepicker({minDate: new Date(2011, 5 - 1, 28), maxDate: new Date(2011, 9 - 1, 18), showOn: "both", dateFormat: "dd/mm/yy", showAnim: "fadeIn", speed: "fast", buttonImage: "http://www.hotelparadiso.it/wp-content/themes/paradisov5/images/ico_calendar.gif", buttonImageOnly: true, hideIfNoPrevNext: true, changeMonth: false, changeYear: false });
	
	// submit form
 	jQuery('#myForm').ajaxForm(function(data) {
            if (data==1){
                jQuery('#success').fadeIn("slow");
                 jQuery('#myForm').slideUp("slow");
                jQuery('#myForm').resetForm();
            }
            else if (data==2){
                jQuery('#badserver').fadeIn("slow");
            }
            else if (data==3)
            {
                jQuery('#bademail').fadeIn("slow");
                setTimeout(function() { 
  				jQuery('#bademail').fadeOut("slow"); 
				}, 10000);
            }
        });

	// Form fields
	jQuery("#bambini").change(function() {
	            var htmlString = "";
	            var len = jQuery("#bambini").val();
	            var nVal = 1;
	            for (var i = 0; i < len; i++) {
	                htmlString += '<div class="hiddenField"><p><label for="eta' + nVal + '">Et&agrave; del ' + nVal + '&deg; bambino:</label> <input type="text" name="eta[]" id="eta' + nVal + '" maxlength="15" value=""  class="txt short" /></p></div>';
	                nVal++;
	            }
	            //alert(htmlString);
	            jQuery("#output").html(htmlString);
	        });

  
});
